import { computed, Ref } from "vue";
export default function OperationHook(state: {
  emit: any;
  loading: Ref<boolean>;
  formState: PaymentApproval.PayableApplyInfo;
  selectMap: Ref<Base.GeneraDataType>;
  customerBillRef: Ref<any>;
  selectUnchargeOff: Ref<string>;
}) {
  const { selectMap, customerBillRef } = state;
  const selectRows = computed<Array<ClientWaybillManagement.ListRows>>(() => {
    return customerBillRef.value.getCheckboxRecords() || [];
  });
  const selectChangeEvent = (e: any, row: any) => {
    selectMap.value[row.id] = e.records;
  };
  const selectAllEvent = (e: any, row: any) => {
    selectMap.value[row.id] = e.records;
  };
  const expandAllEvent = () => {
    const $table = customerBillRef.value;
    if ($table) {
      $table.setAllRowExpand(true);
    }
  };

  const clearExpandEvent = () => {
    const $table = customerBillRef.value;
    if ($table) {
      $table.clearRowExpand();
    }
  };
  return {
    selectRows,
    selectChangeEvent,
    selectAllEvent,
    expandAllEvent,
    clearExpandEvent
  };
}
